import axios from '@/utils/request'
export default {
  Inbound: {
    list: {
      export: {
        query: {
          '@display': `{
            'stock' : 'entity.getStock().getSpecification().getName()',
            'quantity' : 'entity.getQuantity()',
            'unitPrice' : 'entity.getUnitPrice()',
            'comment' : 'entity.getComment()',
            'cretedTime' : 'entity.getCreatedTime().format("Y-m-d H:i:s")'
          }`,
          limit: 10000000
        },
        label: {
          'stock': '产品',
          'quantity': '数量',
          'unitPrice': '单价',
          'comment': '原因',
          'cretedTime': '时间'
        }
      },
      disabled_actions: ['lines', 'delete', 'edit'],
      query: {
        '@order': `entity.createdTime|DESC`
      },
      list_filter: {
        'store.id': () => {
          return axios
            .get(`/manage/stores`)
            .then(res =>
              Object.assign({ __label: '门店' },
                ...res.data.map(v => { return { [v.id]: v.name } })))
        },
        'stock.specification.product.name': '产品',
        startTime: {
          expression: `
          entity.getCreatedTime() >= datetime.get(":value")
        `,
          label: '开始时间',
          type: 'datetime'
        },
        endTime: {
          expression: `
          entity.getCreatedTime() < datetime.get(":value")
        `,
          label: '结束时间',
          type: 'datetime'
        }
      },
      list_display: [
        'store',
        'stock',
        'quantity',
        'unitPrice',
        'status',
        'createdTime'
      ]
    },
    form: {
      fields: [
        'store',
        'stock',
        'quantity',
        'unitPrice',
        'status'
      ]
    }
  }
}

